package com.lac.component.test.singleton;

/**
 * @author xiaokuixiao
 * date2025/4/9 13:35
 */
// 懒汉式(线程安全，同步方法)
class Singleton04{
    private static Singleton04 instance;
    private Singleton04(){

    }

    // 解决线程同步问题
    public static synchronized Singleton04 getInstance(){
        if (instance == null){ //未创建才创建
            instance = new Singleton04();
        }
        return instance;
    }

}